package com.api.shopapi.mapper;


import com.api.shopapi.entity.OrderBusinessTradenoRel;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
public interface OrderBusinessTradenoRelMapper {
    @Insert("insert into order_business_tradeno_rel value" +
            "(" +
            "#{orderBusinessTradenoRel.OrderBusinessTradeNoRelCode}," +
            "#{orderBusinessTradenoRel.OrderBusinessCode}," +
            "#{orderBusinessTradenoRel.TradeNo}" +
            ")")
    public int insert(@Param("orderBusinessTradenoRel") OrderBusinessTradenoRel orderBusinessTradenoRel);

    @Delete("delete from order_business_tradeno_rel where OrderBusinessTradeNoRelCode=#{orderBusinessTradeNoRelCode}")
    public int delete(@Param("orderBusinessTradeNoRelCode") String orderBusinessTradeNoRelCode);

    @Update("update order_business_tradeno_rel set " +
            "OrderBusinessCode = #{orderBusinessTradenoRel.OrderBusinessCode}," +
            "TradeNo = #{orderBusinessTradenoRel.TradeNo} " +
            " where OrderBusinessTradeNoRelCode=#{orderBusinessTradenoRel.OrderBusinessTradeNoRelCode}")
    public int update(@Param("orderBusinessTradenoRel") OrderBusinessTradenoRel orderBusinessTradenoRel);

    @Select("select * from order_business_tradeno_rel")
    public List<OrderBusinessTradenoRel> getList();

    @Select("select * from order_business_tradeno_rel where OrderBusinessTradeNoRelCode=#{orderBusinessTradeNoRelCode} limit 1")
    public OrderBusinessTradenoRel getByOrderBusinessTradeNoRelCode(@Param("orderBusinessTradeNoRelCode") String orderBusinessTradeNoRelCode);

    @Select("select * from order_business_tradeno_rel where tradeno=#{tradeno} ")
    public List<OrderBusinessTradenoRel> getListByTradeno(@Param("tradeno") String tradeno);

    @Select("select * from order_business_tradeno_rel where orderBusinessCode=#{orderBusinessCode} limit 1")
    public OrderBusinessTradenoRel getByOrderBusinessCode(@Param("orderBusinessCode") String orderBusinessCode);

}
